package com.bbcare.exportExcel.plat.vo;

import java.util.ArrayList;
import java.util.List;

public class DataExcel {
    private List<DataExcelSheet> sheets = new ArrayList<>();
    private String name;

    public void addSheet(DataExcelSheet sheet)  {
        this.sheets.add(sheet);
    }
    public List<DataExcelSheet> getAllSheet()   {return this.sheets;}

    public String toString()    {
        StringBuffer sb = new StringBuffer();
        sb.append("本excel文件一共包含"+sheets.size()+"个工作表。\n");
        for(DataExcelSheet sheet : sheets)   {
            sb.append("工作表【"+sheet.getName()+"】包含"+sheet.size()+"行数据。\n");
            sb.append(sheet.toString());
            sb.append("-------------------------------------------------------------\n");
        }
        return sb.toString();
    }
    public List<String> getSheetName()  {
        List<String> sheetNameList  = new ArrayList<>();
        for(DataExcelSheet sheet : this.sheets)   {
            sheetNameList.add(sheet.getName());
        }
        return sheetNameList;
    }
    public DataExcelSheet getSheetByName(final String name)  {
        for(DataExcelSheet sheet : this.sheets)   {
            if (sheet.getName().equals(name))   {
                return sheet;
            }
        }
        return null;
    }
}
